#!/bin/bash
# 安装ssh
if command -v ssh >/dev/null 2>&1; then
    echo "ssh is installed."
else
    echo "ssh未安装,开始安装ssh..."
    apt update
    apt install openssh-server
fi
# 安装curl
if command -v curl >/dev/null 2>&1; then
    echo "curl is installed."
else
    echo "curl未安装,开始安装curl..."
    apt update
    apt install curl
fi
# 安装docker
if command -v docker >/dev/null 2>&1; then
    echo "Docker is installed."
else
    echo "Docker未安装,开始安装Docker..."
    curl -fsSL https://get.docker.com | bash -s docker
    systemctl start docker
    systemctl enable docker
    docker version
fi

# 安装docker-compose
if command -v docker-compose >/dev/null 2>&1; then
    echo "docker-compose is installed."
else
    echo "docker-compose未安装,开始安装docker-compose..."
    apt update
    apt install docker-compose
fi

# 设置合盖不休眠
if cat /etc/systemd/logind.conf | grep '#HandleLidSwitch=suspend'; then
    sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=lock/g' /etc/systemd/logind.conf
    systemctl restart systemd-logind
else
    echo '已设置合盖不休眠'
fi